/**
 * @param {number[]} height
 * @return {number}
 */
 var maxArea = function(height) {
     let max=0;
     let left=0,right=height.length-1;
     while(left<right){
         let s=Math.min(height[right],height[left])*(right-left);
         if(max<s){
             max=s;
         }
         if(height[right]>height[left]){
            left++;
         }
         else{
             right--;
         }
     }
     return max;
};
let s=[1,8,6,2,5,4,8,3,7];
console.log(maxArea(s));